//***************************************************************
//  File:    GameObject.cpp
//  Date:    12/17/2012
//  Author:  liangxc (liangxc2010@gmail.com)
//-------------------------------------------------------------
//
//-------------------------------------------------------------
//  This file is part of Hare2D Game Engine.
//  Copyright (C) All Rights Reserved
//***************************************************************
//
//***************************************************************
#ifndef __SCENEPAGE_H__
#define __SCENEPAGE_H__

#include <wx/harecanvas.h>
#include "graphics/GameObject.h"

class SceneMIMEHandler;

class ScenePage : public EditorPage, public SceneListener
{
	DECLARE_ABSTRACT_CLASS(ImageSpritePage)
public:
	ScenePage(wxWindow* parent, SceneMIMEHandler* handler, SceneManager* s);
	virtual ~ScenePage();

	virtual void setModified(bool modified);
	virtual bool getIsModified() const { return isModified; }
	virtual bool save();
	bool saveAs();

	friend class SceneListenerEditorWrapper<ScenePage>;
	void renderScene();

	void updateTitle();

protected:
	bool isModified;

	wxHareCanvas* spriteCanvas;
	wxHareCanvas* sceneCanvas;
	SceneManager::Ptr sceneManager;
	SceneManager*     spriteScene;
	SceneMIMEHandler* mime;

	Sprite::Ptr curAddSprite;
	Sprite::Ptr curEditSprite;

	wxTreeCtrl*     sceneTree;
	wxPanel*        scenePanel;
	wxPanel*        spritePanel;
	wxListBox*      spriteListCtrl;
	wxToggleButton* btnAddSprite;

	Font::Ptr font;

	wxPoint mouseDownPos;
	wxCursor *dragCursor;

protected:
	void onTreeItemSelected(wxTreeEvent& event);

	void onSceneSize(wxSizeEvent& event);
	void onSceneLButtonDown(wxMouseEvent& event);
	void onSceneLButtonUp(wxMouseEvent& event);
	void onSceneMouseMove(wxMouseEvent& event);

	void onSceneRButtonDown(wxMouseEvent& event);
	void onSceneRButtonUp(wxMouseEvent& event);

	void onSpriteSceneSize(wxSizeEvent& event);
	void onListBoxItemSelected(wxCommandEvent& event);

	void onEraseBackground(wxEraseEvent& event);

public:
	void addSpriteToScene(Sprite* sprite);
};


#endif